<template>
    <h2>添加页面</h2>
    <table class="table table-bordered">
        <tbody>
            <tr>
                <td>头像</td>
                <td>
                    <input type="text" v-model="form.pic">
                </td>
            </tr>
            <tr>
                <td>姓名</td>
                <td>
                    <input type="text" v-model="form.name">
                </td>
            </tr>
            <tr>
                <td>用户名</td>
                <td>
                    <input type="text" v-model="form.userName">
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td>
                    <input type="text" v-model="form.pwd">
                </td>
            </tr>
            <tr>
                <td>电话</td>
                <td>
                    <input type="text" v-model="form.phone">
                </td>
            </tr>
            <tr>
                <td>电子邮件</td>
                <td>
                    <input type="text" v-model="form.email">
                </td>
            </tr>
            <tr>
                <td>性别</td>
                <td>
                    <input type="text" v-model="form.sex">
                </td>
            </tr>
            <tr>
                <td>备注</td>
                <td>
                    <input type="text" v-model="form.beizhu">
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" class="btn btn-primary" @click="Add" value="添加">
                </td>
            </tr>
        </tbody>
    </table>
</template>
<script>
//引入组件
import { ref, reactive, onMounted } from "vue"
//bootstrap样式
import "bootstrap/dist/css/bootstrap.min.css"
//访问后端
import axios from "axios"
//路由(1)
import { useRouter } from "vue-router";

const router = useRouter();
const form = reactive({
    id: 0,
  pic: "",
  name: "",
  pwd: "",
  userName: "",
  phone: "",
  email: "",
  sex: "",
  beizhu: ""
})
const Add = () => {
    axios.post("http://localhost:5156/api/Huiyuan/Add", form).then(res => {
        if (res.data > 0) {
            alert("添加成功！！");
            router.push("/huiyuanShow")
        }
        else {
            alert("添加失败！！");
        }
    })
}
</script>